package com.ysd.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import com.ysd.dao.Impl.CompanyDaoImpl;
import com.ysd.dao.Impl.ProductCatalogueDaoImpl;
import com.ysd.dao.Impl.ProductDaoImpl;
import com.ysd.dao.Impl.ResearchDaoImpl;
import com.ysd.dao.Impl.XinWenAnLiDaoImpl;
import com.ysd.dao.Impl.ZhuYeTuDaoImpl;
import com.ysd.entity.Company;
import com.ysd.entity.Leansnews;
import com.ysd.entity.Product;
import com.ysd.entity.ProductCatalogue;
import com.ysd.entity.Research;

public class HomeServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//调用实现类的方法
		CompanyDaoImpl cDao=new CompanyDaoImpl();
		Company c=cDao.getCompany();
		request.setAttribute("c", c);
		
		//主页产品案例
		ZhuYeTuDaoImpl zyDao=new ZhuYeTuDaoImpl();
		ArrayList<Product> zhuye=zyDao.getZhuYeList();
		request.setAttribute("zhuye", zhuye);
		//主页新闻案例
		XinWenAnLiDaoImpl xDao=new XinWenAnLiDaoImpl();
		ArrayList<Leansnews> xinwen=xDao.getXinWenList();
		request.setAttribute("xinwen",xinwen);
		
		//调用产品分类的实现类
		ProductCatalogueDaoImpl pDao=new ProductCatalogueDaoImpl();
		List<ProductCatalogue> pclist=pDao.getPCList();
		request.setAttribute("pclist", pclist);
		request.getRequestDispatcher("index.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
